package com.jingdianjichi.oss.service;

import com.jingdianjichi.oss.adapter.StorageAdapter;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * FileService 类
 *
 * @author 熊苏鹏1
 * @date 2025/2/27 21:31
 * @description
 */
@Service
public class FileService {
    //自动注入
    private final StorageAdapter storageAdapter;

    public FileService(StorageAdapter storageAdapter) {
        this.storageAdapter = storageAdapter;
    }
    public List<String> getAllBucket(){
        return storageAdapter.getAllBucket();
    }
    public void uploadFile(MultipartFile uploadFile, String bucket, String objectName){
        storageAdapter.uploadFile(uploadFile,bucket,objectName);
    }

    public String getUrl(String bucket, String objectName) {
        return storageAdapter.getUrl(bucket, objectName);
    }
}
